package com.focus.xyz.other.pages.pingan;

import com.focus.xyz.core.common.keyword.Action;
import com.focus.xyz.core.pages.BasePage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

/**
 * Created by chenmeng on 2016/6/29.
 */
public class ResultPage extends BasePage {
    private Action action;
    private WebDriver driver;
    @FindBy(xpath = "//button[contains(text(),'确定')]")
    private WebElement confirmBtn;
    @FindBy(xpath = "//input[@type='button' and @value='确定']")
    private WebElement noResultConfirm;

    public ResultPage(WebDriver driver, Action action) {
        super(driver, action);
        this.action = action;
        this.driver = driver;
        PageFactory.initElements(this.driver,this);
    }

    public void confirmCarInfo() throws Exception{
        if(driver.getPageSource().contains("未查到往年保单记录")){
            action.click(noResultConfirm);
        }else{
            action.click(confirmBtn);
            action.pause(2000l);
        }
        action.switchToParentWindow("https://icorepnbs.pingan.com.cn/icore_pnbs/");
    }


}
